<template>
  <div >
    <el-breadcrumb>
      <el-breadcrumb-item>出库管理</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="UserFormBox">
      <el-form ref="userFormRef" :model="deliveryForm" :rules="deliveryFormRules" class="UserForm_sty">
        <el-form-item prop="del_id">
          <el-input v-model="deliveryForm.del_id">
            <template slot="prepend">提单号</template>
          </el-input>
        </el-form-item>
        <el-form-item prop="del_date">
          <el-input v-model="deliveryForm.del_date">
            <template slot="prepend">出库日期</template>
          </el-input>
        </el-form-item>
        <el-form-item prop="del_piece">
          <el-input v-model="deliveryForm.del_piece">
            <template slot="prepend">出库件数</template>
          </el-input>
        </el-form-item>
        <el-form-item prop="del_ton">
          <el-input v-model="deliveryForm.del_ton">
            <template slot="prepend">出库吨数</template>
          </el-input>
        </el-form-item>
        <el-form-item prop="del_surplus">
          <el-input v-model="deliveryForm.del_surplus">
            <template slot="prepend">剩余吨数</template>
          </el-input>
        </el-form-item>
        <el-form-item class="btns">
          <el-button type="primary" @click="inserDelivery" round>提交</el-button>
          <el-button type="info" @click="resetuserForm" round>重置</el-button>
        </el-form-item>
      </el-form>
      <el-dialog
        title="提示"
        :visible.sync="sucessVisible"
        width="30%">
        <span>提交成功</span>
        <span slot="footer" class="dialog-footer">
          <el-button @click="sucessVisible = false">取 消</el-button>
          <el-button type="primary" @click="sucessVisible = false">确 定</el-button>
        </span>
      </el-dialog>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      deliveryForm: {
        del_id: '',
        del_date: '',
        del_piece: '',
        del_ton: '',
        del_surplus: ''
      },
      deliveryFormRules: {
        del_id: [
          { required: true, message: '请输入提单号', trigger: 'blur' }
        ],
        del_date: [
          { required: true, message: '请输入出库日期', trigger: 'blur' }
        ],
        del_piece: [
          { required: true, message: '请输入出库件数', trigger: 'blur' }
        ],
        del_ton: [
          { required: true, message: '请输入出库吨数', trigger: 'blur' }
        ],
        del_surplus: [
          { required: true, message: '请输入剩余吨数', trigger: 'blur' }
        ]
      },
      sucessVisible: false
    }
  },
  methods: {
    resetuserForm() {
      this.$refs.userFormRef.resetFields()
    },
    inserDelivery() {
      const { data: res } = this.$http.post('delivery', {
        del_id: this.deliveryForm.del_id,
        del_date: this.deliveryForm.del_date,
        del_piece: this.deliveryForm.del_piece,
        del_ton: this.deliveryForm.del_ton,
        del_surplus: this.deliveryForm.del_surplus
      })
      this.emidtsucess()
      console.log(res)
    },
    emidtsucess() {
      this.sucessVisible = true
    }
  }
}
</script>

<style lang="less" scoped>
  .el-form-item{
    width: 500px;
  }
  .UserFormBox{
    background-color: #fffffb;
    height: 435px;
    width: 1210px;
    border-radius: 5px;
    margin-left: 10px;
  }
  .UserForm_sty{
    position: absolute;
    padding: 30px 60px 30px;
    box-sizing: border-box;
  }
  .btns{
    display: flex;
    justify-content: flex-start;
    margin-top: 60px;
  }
</style>
